package github.flandre.examplemod.common.item;

import github.flandre.examplemod.common.world.ExampleWorldSaveData;
import github.flandre.examplemod.core.init.Itemgroup.ExampleGroup;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;

public class ExampleItem extends Item {
    public ExampleItem() {
        super(new Item.Properties().group(ExampleGroup.exampleGroup));//group 放到哪个组里面
    }

    @Override
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {

        if(!worldIn.isRemote)
        {
            int power = ExampleWorldSaveData.get(worldIn).getPower();
            ExampleWorldSaveData.get(worldIn).setPower(power + 1);
            playerIn.sendMessage(new StringTextComponent(String.valueOf(power + 1)),playerIn.getUniqueID());
        }
        return super.onItemRightClick(worldIn, playerIn, handIn);
    }


}


